﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using ZLDC.Common.Estate;

namespace ZLDC.DAL.Estate
{
    public class DayReportReplyDAL
    {
        public static void p_dayReport_Reply_save(int Id, int reportId, string replycontent, int userid, string user, int deptid, string dept, out string outmsg, out int newid, _Database db)
        {
            List<SqlParameter> parms = new List<SqlParameter>();

            parms.Add(new SqlParameter("@Id", Id));
            parms.Add(new SqlParameter("@reportId", reportId));
            parms.Add(new SqlParameter("@replycontent", replycontent));
            parms.Add(new SqlParameter("@userid", userid));
            parms.Add(new SqlParameter("@user", user));
            parms.Add(new SqlParameter("@deptid", deptid));
            parms.Add(new SqlParameter("@dept", dept));

            SqlParameter pOutmsg = new SqlParameter("@outmsg", SqlDbType.VarChar, 256);
            pOutmsg.Direction = ParameterDirection.Output;
            parms.Add(pOutmsg);

            SqlParameter pNewid = new SqlParameter("@newid", SqlDbType.Int, 4);
            pNewid.Direction = ParameterDirection.Output;
            parms.Add(pNewid);
            SqlParameter pRetval = new SqlParameter("@retval", SqlDbType.Int, 4);
            pRetval.Direction = ParameterDirection.ReturnValue;
            parms.Add(pRetval);


            db.execute_procedure("p_dayReport_Reply_save", parms);

            outmsg = (pOutmsg.Value == System.DBNull.Value) ? "" : Convert.ToString(pOutmsg.Value);
            newid = (pNewid.Value == System.DBNull.Value) ? 0 : Convert.ToInt32(pNewid.Value);

            int retval = (pRetval.Value == System.DBNull.Value) ? 0 : Convert.ToInt32(pRetval.Value);

        }
        public static DataSet SelectDayReportReplyListById(int id, _Database db)
        {
            DataSet ds = null;

            try
            {

                string sql = "select * from t_dayReport_reply where reportid=" + id + "";
                ds = db.Query(sql);

            }
            catch { }
            finally
            {
                db.close();
            }
            return ds;
        }

    }
}
